import 'dart:async';
import 'dart:io';

import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:management/model/department_model.dart';
import 'package:management/model/open_gate_record_model.dart';
import 'package:management/model/user_model.dart';
import 'package:management/model/visit_matter_model.dart';
import 'package:management/utils/convert.dart';
import 'package:management/utils/log_utils.dart';
import 'package:permission_handler/permission_handler.dart';

// import 'package:permission_handler/permission_handler.dart';
import 'package:sqflite/sqflite.dart';

import 'gate_model.dart';

///数据库名称[management.db]
final String dbName = 'management.db';

///存放访客记录的表名 [visitor]
const String tableVisitor = "visitor";

/********************************* visitor 表字段 ******************************************/

///姓名
final String columnName = 'name';

///性别
final String columnGender = 'gender';

///民族
final String columnNationality = 'nationality';

///出生日期
final String columnDateOfBirth = 'dateOfBirth';

///证件类型
final String columnTypeOfCertificate = 'typeOfCertificate';

///证件号码
final String columnIDNumber = 'IDNumber';

///联系电话
final String columnTelephoneNum = 'telephoneNum';

///访客住址
final String columnVisitorAddress = 'visitorAddress';

///访客单位
final String columnVisitorUnit = 'visitorUnit';

///被访部门
final String columnDepartmentInterviewed = 'departmentInterviewed';

///被访人
final String columnInterviewee = 'interviewee';

///来访事项
final String columnVisitingMatters = 'visitingMatters';

///备注
final String columnRemarks = 'remarks';

///携带物品
final String columnWhatToBring = 'whatToBring';

///车牌号码
final String columnLicensePlateNumber = 'licensePlateNumber';

///随行访客人数
final String columnNumberOfAccompanyingVisitors =
    'numberOfAccompanyingVisitors';

///登记点
final String columnRegistrationPoint = 'registrationPoint';

///登记日期
final String columnRegistrationDate = 'registrationDate';

///登记时间
final String columnCheckInTime = 'checkInTime';

/// ********************************************************************************************/
String? dbPath;

///访客对象
class Visitor {
  String? name;
  String? gender;
  String? nationality;
  String? dateOfBirth;
  String? typeOfCertificate;
  String? IDNumber;
  String? telephoneNum;
  String? visitorAddress;
  String? visitorUnit;
  String? departmentInterviewed;
  String? interviewee;
  String? visitingMatters;
  String? remarks;
  String? whatToBring;
  String? licensePlateNumber;
  String? numberOfAccompanyingVisitors;
  String? registrationPoint;
  String? registrationDate;
  String? checkInTime;

  Map<String, Object?> toMap() {
    var map = <String, Object?>{
      columnName: name, //访客姓名
      columnGender: gender, //性别
      columnNationality: nationality, //民族
      columnDateOfBirth: dateOfBirth, //出生日期
      columnTypeOfCertificate: typeOfCertificate, //证件类型
      columnIDNumber: IDNumber, //证件号码
      columnTelephoneNum: telephoneNum, //联系电话
      columnVisitorAddress: visitorAddress, //访客住址
      columnVisitorUnit: visitorUnit, //访客单位
      columnDepartmentInterviewed: departmentInterviewed,
      columnInterviewee: interviewee,
      columnVisitingMatters: visitingMatters,
      columnRemarks: remarks,
      columnWhatToBring: whatToBring,
      columnLicensePlateNumber: licensePlateNumber,
      columnNumberOfAccompanyingVisitors: numberOfAccompanyingVisitors,
      columnRegistrationPoint: registrationPoint,
      columnRegistrationDate: registrationDate,
      columnCheckInTime: checkInTime,
    };
    return map;
  }

  Visitor(this.name, this.gender, this.typeOfCertificate, this.IDNumber,
      {this.nationality,
      this.dateOfBirth,
      this.telephoneNum,
      this.visitorAddress,
      this.visitorUnit,
      this.departmentInterviewed,
      this.interviewee,
      this.visitingMatters,
      this.remarks,
      this.whatToBring,
      this.licensePlateNumber,
      this.numberOfAccompanyingVisitors,
      this.registrationPoint,
      this.registrationDate,
      this.checkInTime});

  Visitor.fromMap(Map<String, Object?> map) {
    name = map[columnName] as String?;
    gender = map[columnGender] as String?;
    nationality = map[columnNationality] as String?;
    dateOfBirth = map[columnDateOfBirth] as String?;
    typeOfCertificate = map[columnTypeOfCertificate] as String?;
    IDNumber = map[columnIDNumber] as String?;
    telephoneNum = map[columnTelephoneNum] as String?;
    visitorAddress = map[columnVisitorAddress] as String?;
    visitorUnit = map[columnVisitorUnit] as String?;
    departmentInterviewed = map[columnDepartmentInterviewed] as String?;
    interviewee = map[columnInterviewee] as String?;
    visitingMatters = map[columnVisitingMatters] as String?;
    remarks = map[columnRemarks] as String?;
    whatToBring = map[columnWhatToBring] as String?;
    licensePlateNumber = map[columnLicensePlateNumber] as String?;
    numberOfAccompanyingVisitors = map[columnNumberOfAccompanyingVisitors] as String?;
    registrationPoint = map[columnRegistrationPoint] as String?;
    registrationDate = map[columnRegistrationDate] as String?;
    checkInTime = map[columnCheckInTime] as String?;
  }
}

///访客登记表帮助类
/// Supported SQLite types
/// No validity check is done on values yet so please avoid non supported types https://www.sqlite.org/datatype3.html
///
/// DateTime is not a supported SQLite type. Personally I store them as int (millisSinceEpoch) or string (iso8601)
///
/// bool is not a supported SQLite type. Use INTEGER and 0 and 1 values.
///
/// More information on supported types here.
///
/// INTEGER
/// Dart type: int
/// Supported values: from -2^63 to 2^63 - 1
///
/// REAL
/// Dart type: num
///
/// TEXT
/// Dart type: String
///
/// BLOB
/// Dart type: Uint8List
class VisitorProvider {
  Database? db;

  VisitorProvider._();

  static final VisitorProvider provider = VisitorProvider._();

  ///数据库初始化
  Future initDB() async {
    WidgetsFlutterBinding.ensureInitialized();

    // String dbPath = "/sdcard/Management/databases/management.db";

    // You can request multiple permissions at once.
    await requestPermission();
    File dbFile;
    if (SpUtil.getInt('sdkInt') == 29) {
      dbPath = await getDatabasesPath() + "/management.db";
      dbFile = File(dbPath!);
    } else {
      dbPath = "/sdcard/Management/databases/management.db";
      dbFile = File(dbPath!);
    }
    if (!await dbFile.exists()) {
      dbFile.create(recursive: true);
    }
    MyLog.i("数据库位置：$dbFile.absolute.path");
    dbPath = dbFile.absolute.path;
    this.db = await createTable(dbPath!);
    UserProvider.instance.init();
  }

  Future requestPermission() async {
    Map<Permission, PermissionStatus> statuses = await [
      Permission.location,
      Permission.storage,
      Permission.microphone,
      Permission.camera,
      Permission.requestInstallPackages,
      Permission.bluetooth
    ].request();
  //
  //   MyLog.i("location:${statuses[Permission.location]}");
  //   MyLog.i("storage: ${statuses[Permission.storage]}");
  //   MyLog.i("microphone: ${statuses[Permission.microphone]}");
  //   MyLog.i("camera: ${statuses[Permission.camera]}");
  //   MyLog.i("bluetooth: ${statuses[Permission.bluetooth]}");
  //   MyLog.i(
  //       "requestInstallPackages: ${statuses[Permission.requestInstallPackages]}");
  }

  final String sqlCreateTableVisitor =
      """create table if not exists $tableVisitor(
      $columnName text not null,
      $columnGender text not null,
      $columnNationality text,
      $columnDateOfBirth text,
      $columnTypeOfCertificate text not null,
      $columnIDNumber text not null,
      $columnTelephoneNum text,
      $columnVisitorAddress text,
      $columnVisitorUnit text,
      $columnDepartmentInterviewed text,
      $columnInterviewee text,
      $columnVisitingMatters text,
      $columnRemarks text,
      $columnWhatToBring text,
      $columnLicensePlateNumber text,
      $columnNumberOfAccompanyingVisitors text,
      $columnRegistrationPoint text,
      $columnRegistrationDate text,
      $columnCheckInTime text);""";

  String sqlCreateTableGate = """create table if not exists $tableGate(
    $columnGateName text,
    $columnDepartmentId text,
    $columnDeviceId text,
    $columnGateMac text);
  """;

  String sqlCreateTableUser = """create table if not exists $tableUser(
    $columnUserName text,
    $columnUserPassWord text,
    $columnUserFaceToken text);
  """;

  String sqlCreateTableGateRecord =
      """create table if not exists $tableGateRecord(
      $columnGateRecordControlType integer,
      $columnGateName text,
      $columnGateRecordTime text,
      $columnGateRecordGateMac text,
      $columnGateRecordOperator text,
      $columnGateRecordPasserby text);
      """;

  String sqlCreateTableDepartment = """
  create table if not exists $tableDepartment(
  $columnDepartmentName text);
  """;

  String sqlCreateTableVisitMatter = """
  create table if not exists $tableVisitMatter($columnMatter text);""";

  ///打开数据库
  ///
  Future<Database> createTable(String path) async {
    return await openDatabase(
      path,
      version: 1,
      onCreate: (Database db, int version) async {
        var batch = db.batch();
        batch.execute(sqlCreateTableVisitor);
        batch.execute(sqlCreateTableGate);
        batch.execute(sqlCreateTableUser);
        batch.execute(sqlCreateTableGateRecord);
        batch.execute(sqlCreateTableDepartment);
        batch.execute(sqlCreateTableVisitMatter);
        insertDataToTableDepartment(batch);
        insertDataToTableVisitMatter(batch);
        await batch.commit(continueOnError: true, noResult: true);
        db.close();
      },
      // onUpgrade: _onUpgrade(await openDatabase(path), 1, 1),
    );
  }

  ///数据库升级
  ///
  FutureOr<void> _onUpgrade(Database db, int oldVersion, int newVersion) async {
    MyLog.w("oldVersion: $oldVersion newVersion: $newVersion");
    if (newVersion == 1) {
      var batch = db.batch();
      batch.execute(sqlCreateTableVisitMatter);
      insertDataToTableVisitMatter(batch);
      batch.commit(continueOnError: true, noResult: true);
      db.close();
    }
  }

  void insertDataToTableDepartment(Batch batch) {
    batch.execute("insert into $tableDepartment (name) values (\"后勤部\")");
    batch.execute("insert into $tableDepartment (name) values (\"总务处\")");
    batch.execute("insert into $tableDepartment (name) values (\"保卫室\")");
    batch.execute("insert into $tableDepartment (name) values (\"总务处\")");
    batch.execute("insert into $tableDepartment (name) values (\"招生处\")");
    batch.execute("insert into $tableDepartment (name) values (\"总务处\")");
    batch.execute("insert into $tableDepartment (name) values (\"开发部\")");
    batch.execute("insert into $tableDepartment (name) values (\"市场部\")");
    batch.execute("insert into $tableDepartment (name) values (\"销售部\")");
    batch.execute("insert into $tableDepartment (name) values (\"行政部\")");
    batch.execute("insert into $tableDepartment (name) values (\"无\")");
    batch.execute("insert into $tableDepartment (name) values (\"其他\")");
  }

  void insertDataToTableVisitMatter(Batch batch) {
    batch.execute("insert into $tableVisitMatter values(\"面试\")");
    batch.execute("insert into $tableVisitMatter values(\"快递\")");
    batch.execute("insert into $tableVisitMatter values(\"外卖\")");
    batch.execute("insert into $tableVisitMatter values(\"洽谈\")");
    batch.execute("insert into $tableVisitMatter values(\"学习\")");
    batch.execute("insert into $tableVisitMatter values(\"考察\")");
    batch.execute("insert into $tableVisitMatter values(\"探亲\")");
    batch.execute("insert into $tableVisitMatter values(\"员工来访\")");
    batch.execute("insert into $tableVisitMatter values(\"出差\")");
    batch.execute("insert into $tableVisitMatter values(\"其他\")");
  }

  ///插入表记录
  Future<Visitor> insert(Visitor visitor,
      {String tableName = tableVisitor}) async {
    await open();
    db!.insert(tableName, visitor.toMap());
    close();
    return visitor;
  }

  ///根据姓名查出  姓名 身份证类型 身份证号码
  Future<Visitor?> getVisitor(String name,
      {String tableName = tableVisitor}) async {
    await open();
    List<Map<String, Object?>> maps = await db!.query(tableVisitor,
        columns: [columnName, columnTypeOfCertificate, columnIDNumber],
        where: '$columnName = ?',
        whereArgs: [name]);
    if (maps.length > 0) {
      close();
      return Visitor.fromMap(maps.first);
    }
    close();
    return null;
  }

  ///查询所有记录
  Future<List<Visitor>?> getAllVisitor({String tableName = tableVisitor}) async {
    await open();
    List<Map<String,Object?>> maps = await db!.rawQuery('select * from $tableName');

    if (maps.length > 0) {
      List<Visitor> allVisitor = [];
      maps.forEach((element) {
        allVisitor.add(Visitor.fromMap(element));
      });
      close();
      return allVisitor;
    }
    close();
    return null;
  }

  Future open() async {
    db = await openDatabase(dbPath!);
  }

  /// 删除一条记录
  Future<int> delete(Visitor visitor, {String tableName = tableVisitor}) async {
    await open();
    int count = await db!.delete(tableName,
        where: '$columnName = ? and $columnGender = ? and $columnIDNumber = ?'
            'and $columnRegistrationDate = ?  and $columnCheckInTime = ?',
        whereArgs: [
          visitor.name,
          visitor.gender,
          visitor.IDNumber,
          visitor.registrationDate,
          visitor.checkInTime
        ]);
    close();
    return count;
  }

  Future deleteByTime(String startTime, String endTime) async {
    await open();

    await db!.delete(tableVisitor,
        where: '$columnRegistrationDate between ? and ?',
        whereArgs: [startTime, endTime]);
    close();
  }

  ///删除所有表记录记录
  Future<int> deleteAll({String tableName = tableVisitor}) async {
    await open();
    int count = await db!.rawDelete(
      'delete from $tableName',
    );
    close();
    return count;
  }

  ///更新表记录
  Future<int> update(Visitor visitor, {String tableName = tableVisitor}) async {
    await open();
    int count = await db!.update(tableName, visitor.toMap(),
        where: '$columnName = ?', whereArgs: [visitor.name]);
    close();
    return count;
  }

  ///一个月前的格式化时间
  String getFormatTimeAMonthAgo() {
    var now_dateTime = DateTime.now();
    //1个月前是几月
    var a_month_ago_month;

    ///1个月前的年份
    var a_month_ago_year;

    if (now_dateTime.month - 1 == 0) {
      a_month_ago_month = 12;
      a_month_ago_year = now_dateTime.year - 1;
    } else {
      a_month_ago_month = now_dateTime.month - 1;
      a_month_ago_year = now_dateTime.year;
    }

    return Convert.format(DateTime(a_month_ago_year, a_month_ago_month));
  }

  ///两个月前的格式化时间
  String getFormatTime2MonthAgo() {
    var dateTime = DateTime.now();
    //2个月前是几月
    var two_month_ago_month;

    ///2个月前的年份
    var two_month_ago_year;

    switch (dateTime.month - 2) {
      case -1:
        two_month_ago_month = 11;
        two_month_ago_year = dateTime.year - 1;
        break;
      case 0:
        two_month_ago_month = 12;
        two_month_ago_year = dateTime.year - 1;
        break;
      default:
        two_month_ago_month = dateTime.month;
        two_month_ago_year = dateTime.year;
        break;
    }
    return Convert.format(DateTime(two_month_ago_year, two_month_ago_month));
  }

  ///三个月前的格式化时间 粗略计算 月份减三
  String getFromatTime3MonthAgo() {
    var now_dateTime = DateTime.now();
    //三个月前是几月
    var three_month_ago_month;

    ///三个月前的年份
    var three_month_ago_year;
    switch (now_dateTime.month - 3) {
      case -2:
        three_month_ago_month = 10;
        three_month_ago_year = DateTime.now().year - 1;
        break;
      case -1:
        three_month_ago_month = 11;
        three_month_ago_year = DateTime.now().year - 1;
        break;
      case 0:
        three_month_ago_month = 12;
        three_month_ago_year = DateTime.now().year - 1;
        break;
      default:
        three_month_ago_month = now_dateTime.month - 3;
        three_month_ago_year = DateTime.now().year;
    }

    var format_time =
        Convert.format(DateTime(three_month_ago_year, three_month_ago_month));
    return format_time;
  }

  ///查被访人历史记录
  ///[mode] 一个月前 1  两个月前 2 三个月前 3
  Future<List<String>?> queryInterviewee(int mode) async {
    var formatTime;
    switch (mode) {
      case 1:
        formatTime = getFormatTimeAMonthAgo();
        break;
      case 2:
        formatTime = getFormatTime2MonthAgo();
        break;
      case 3:
        formatTime = getFromatTime3MonthAgo();
        break;
    }

    MyLog.d("$formatTime");
    await open();

    List<Map<String, Object?>> maps = await db!.query(
      tableVisitor,
      distinct: true,
      columns: [columnInterviewee],
      where:
          "$columnInterviewee != ? and $columnInterviewee != ? and $columnRegistrationDate > ?",
      whereArgs: ["", "无", formatTime],
      limit: 6,
    );
    if (maps.length > 0) {
      List<String> result = [];
      maps.forEach((element) {
        if (!TextUtil.isEmpty(element[columnInterviewee].toString())) {
          result.add(element[columnInterviewee].toString());
        }
      });
      close();
      return result;
    }
    close();
    return null;
  }

  ///关闭数据库
  Future close() async => db!.close();

  ///根据条件查询
  Future<List<Visitor>?> getVisitorByCondition(
      {String? name,
      String? gender,
      String? departmentInterviewee,
      String? interviewee,
      String? visitMatter,
      String? licensePlateNumber,
      String? startDate,
      String? endDate}) async {
    await open();
    // 满足所有条件查询
    // List<Map> maps = await db!.query(tableVisitor,
    //     columns: null,
    //     where:
    //     '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? '
    //         'and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? '
    //         'and $columnRegistrationDate between ? and ?',
    //     whereArgs: [
    //       name,
    //       gender,
    //       departmentInterviewee,
    //       interviewee,
    //       visitMatter,
    //       licensePlateNumber,
    //       startDate,
    //       endDate
    //     ]);
    List<Map<String,Object?>> maps;
    List<Visitor>? allVisitor = [];

    if (TextUtil.isEmpty(name)) {
      if (TextUtil.isEmpty(gender)) {
        if (TextUtil.isEmpty(departmentInterviewee)) {
          if (TextUtil.isEmpty(interviewee)) {
            if (TextUtil.isEmpty(visitMatter)) {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //都为空 则查找所有记录
                    return allVisitor = await getAllVisitor();
                  } else {
                    // 结束日期
                    maps = await db!.query(tableVisitor,
                        where: '$columnRegistrationDate <= ?',
                        whereArgs: [endDate]);
                  }
                } else {
                  // 开始日期
                  if (TextUtil.isEmpty(endDate)) {
                    maps = await db!.query(tableVisitor,
                        where: '$columnRegistrationDate >= ?',
                        whereArgs: [startDate]);
                  } else {
                    // 开始日期  结束日期
                    maps = await db!.query(tableVisitor,
                        where: '$columnRegistrationDate between ? and ?',
                        whereArgs: [startDate, endDate]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //车牌号码
                    maps = await db!.query(tableVisitor,
                        where: '$columnLicensePlateNumber = ?',
                        whereArgs: [columnLicensePlateNumber]);
                  } else {
                    //车牌号码 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnLicensePlateNumber = ? and $columnRegistrationDate',
                        whereArgs: [licensePlateNumber, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //车牌号码 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnLicensePlateNumber = ? and $columnRegistrationDate',
                        whereArgs: [licensePlateNumber, startDate]);
                  } else {
                    //车牌号码 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [licensePlateNumber, startDate, endDate]);
                  }
                }
              }
            } else {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //来访事由
                    maps = await db!.query(tableVisitor,
                        where: '$columnVisitingMatters = ?',
                        whereArgs: [visitMatter]);
                  } else {
                    //来访事由 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnVisitingMatters = ? and $columnRegistrationDate <= ?',
                        whereArgs: [visitMatter, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //来访事由 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnVisitingMatters = ? and $columnRegistrationDate >= ?',
                        whereArgs: [visitMatter, startDate]);
                  } else {
                    //来访事由 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnVisitingMatters = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [visitMatter, startDate, endDate]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //来访事由 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnVisitingMatters = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [visitMatter, licensePlateNumber]);
                  } else {
                    //来访事由 车牌号码 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [visitMatter, licensePlateNumber, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //来访事由 车牌号码 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          visitMatter,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //来访事由 车牌号码 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnVisitingMatters = and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          visitMatter,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            }
          } else {
            if (TextUtil.isEmpty(visitMatter)) {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    // 被访人
                    maps = await db!.query(tableVisitor,
                        where: '$columnInterviewee = ? ',
                        whereArgs: [interviewee]);
                  } else {
                    // 被访人 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnInterviewee = ? and $columnRegistrationDate <= ? ',
                        whereArgs: [interviewee, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访人 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnInterviewee = ? and $columnRegistrationDate >= ?',
                        whereArgs: [interviewee, startDate]);
                  } else {
                    //被访人 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnInterviewee = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [interviewee, startDate, endDate]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访人  车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnInterviewee = ?  and $columnLicensePlateNumber = ?',
                        whereArgs: [interviewee, licensePlateNumber]);
                  } else {
                    //被访人  车牌号码 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnInterviewee = ?  and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [interviewee, licensePlateNumber, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访人 车牌号码 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnInterviewee = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          interviewee,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //被访人 车牌号码 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnInterviewee = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          interviewee,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            } else {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    // 被访人 来访事项
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnInterviewee = ? and $columnVisitingMatters = ?',
                        whereArgs: [interviewee, visitMatter]);
                  } else {
                    // 被访人 来访事项  结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate <= ?',
                        whereArgs: [interviewee, visitMatter, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    // 被访人 来访事项  开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate >= ?',
                        whereArgs: [interviewee, visitMatter, startDate]);
                  } else {
                    // 被访人 来访事项  开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          interviewee,
                          visitMatter,
                          startDate,
                          endDate
                        ]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访人 来访事由 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [
                          interviewee,
                          visitMatter,
                          licensePlateNumber
                        ]);
                  } else {
                    //被访人 来访事由 车牌号码  结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访人 来访事由 车牌号码  开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //被访人 来访事由 车牌号码  开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            }
          }
        } else {
          if (TextUtil.isEmpty(interviewee)) {
            if (TextUtil.isEmpty(visitMatter)) {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访部门
                    maps = await db!.query(tableVisitor,
                        where: '$columnDepartmentInterviewed = ?',
                        whereArgs: [departmentInterviewee]);
                  } else {
                    //被访部门 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnRegistrationDate <= ?',
                        whereArgs: [departmentInterviewee, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访部门 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnRegistrationDate >= ?',
                        whereArgs: [departmentInterviewee, startDate]);
                  } else {
                    //被访部门 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [departmentInterviewee, startDate, endDate]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访部门 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [departmentInterviewee, licensePlateNumber]);
                  } else {
                    //被访部门 车牌号码 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          departmentInterviewee,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访部门  车牌号码 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          departmentInterviewee,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //被访部门 车牌号码 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          departmentInterviewee,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            } else {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访部门 来访事由
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnVisitingMatters = ? ',
                        whereArgs: [departmentInterviewee, visitMatter]);
                  } else {
                    //被访部门 来访事由 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          departmentInterviewee,
                          visitMatter,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访部门 来访事由 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          departmentInterviewee,
                          visitMatter,
                          startDate
                        ]);
                  } else {
                    //被访部门 来访事由 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          departmentInterviewee,
                          visitMatter,
                          startDate,
                          endDate
                        ]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访部门 来访事由 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [
                          departmentInterviewee,
                          visitMatter,
                          licensePlateNumber
                        ]);
                  } else {
                    //被访部门 来访事由 车牌号码 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          departmentInterviewee,
                          visitMatter,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访部门  来访事由 车牌号码 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          departmentInterviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //被访部门 来访事由 车牌号码 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          departmentInterviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            }
          } else {
            if (TextUtil.isEmpty(visitMatter)) {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访部门 被访人
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnInterviewee = ?',
                        whereArgs: [departmentInterviewee, interviewee]);
                  } else {
                    //被访部门 被访人 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          departmentInterviewee,
                          interviewee,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访部门 被访人 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          departmentInterviewee,
                          interviewee,
                          startDate
                        ]);
                  } else {
                    //被访部门 被访人 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          departmentInterviewee,
                          interviewee,
                          startDate,
                          endDate
                        ]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访部门 被访人 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [
                          departmentInterviewee,
                          interviewee,
                          licensePlateNumber
                        ]);
                  } else {
                    //被访部门 被访人 车牌号码 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          departmentInterviewee,
                          interviewee,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访部门  被访人 车牌号码 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          departmentInterviewee,
                          interviewee,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //被访部门 被访人 车牌号码 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          departmentInterviewee,
                          interviewee,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            } else {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访部门 被访人 来访事由
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? ',
                        whereArgs: [
                          departmentInterviewee,
                          interviewee,
                          visitMatter
                        ]);
                  } else {
                    //被访部门 被访人 来访事由 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访部门 被访人 来访事由 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          startDate
                        ]);
                  } else {
                    //被访部门 被访人 来访事由 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          startDate,
                          endDate
                        ]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访部门 被访人 来访事由 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          licensePlateNumber
                        ]);
                  } else {
                    //被访部门 被访人 来访事由 车牌号码 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访部门  被访人 来访事由 车牌号码 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //被访部门 被访人 来访事由 车牌号码 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            }
          }
        }
      } else {
        if (TextUtil.isEmpty(departmentInterviewee)) {
          if (TextUtil.isEmpty(interviewee)) {
            if (TextUtil.isEmpty(visitMatter)) {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别
                    maps = await db!.query(tableVisitor,
                        where: '$columnGender = ?', whereArgs: [gender]);
                  } else {
                    // 性别 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnRegistrationDate <= ?',
                        whereArgs: [gender, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    // 性别 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnRegistrationDate >= ?',
                        whereArgs: [gender, startDate]);
                  } else {
                    // 性别 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [gender, startDate, endDate]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [gender, columnLicensePlateNumber]);
                  } else {
                    //性别 车牌号码 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate',
                        whereArgs: [gender, licensePlateNumber, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 车牌号码 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate',
                        whereArgs: [gender, licensePlateNumber, startDate]);
                  } else {
                    //性别 车牌号码 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          gender,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            } else {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 来访事由
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnVisitingMatters = ?',
                        whereArgs: [gender, visitMatter]);
                  } else {
                    //性别 来访事由 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnVisitingMatters = ? and $columnRegistrationDate <= ?',
                        whereArgs: [gender, visitMatter, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 来访事由 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnVisitingMatters = ? and $columnRegistrationDate >= ?',
                        whereArgs: [gender, visitMatter, startDate]);
                  } else {
                    //性别 来访事由 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnVisitingMatters = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [gender, visitMatter, startDate, endDate]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 来访事由 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [gender, visitMatter, licensePlateNumber]);
                  } else {
                    //性别 来访事由 车牌号码 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          gender,
                          visitMatter,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 来访事由 车牌号码 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          gender,
                          visitMatter,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //性别 来访事由 车牌号码 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnVisitingMatters = and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          gender,
                          visitMatter,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            }
          } else {
            if (TextUtil.isEmpty(visitMatter)) {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访人
                    maps = await db!.query(tableVisitor,
                        where: '$columnGender = ? and $columnInterviewee = ? ',
                        whereArgs: [gender, interviewee]);
                  } else {
                    //性别 被访人 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnInterviewee = ? and $columnRegistrationDate <= ? ',
                        whereArgs: [gender, interviewee, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访人 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnInterviewee = ? and $columnRegistrationDate >= ?',
                        whereArgs: [gender, interviewee, startDate]);
                  } else {
                    //性别 被访人 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnInterviewee = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [gender, interviewee, startDate, endDate]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //被访人  车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnInterviewee = ?  and $columnLicensePlateNumber = ?',
                        whereArgs: [interviewee, licensePlateNumber]);
                  } else {
                    //被访人  车牌号码 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnInterviewee = ?  and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [interviewee, licensePlateNumber, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访人 车牌号码 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          gender,
                          interviewee,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //性别 被访人 车牌号码 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          gender,
                          interviewee,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            } else {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访人 来访事项
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnInterviewee = ? and $columnVisitingMatters = ?',
                        whereArgs: [gender, interviewee, visitMatter]);
                  } else {
                    //性别 被访人 来访事项  结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate <= ?',
                        whereArgs: [gender, interviewee, visitMatter, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访人 来访事项  开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          gender,
                          interviewee,
                          visitMatter,
                          startDate
                        ]);
                  } else {
                    //性别 被访人 来访事项  开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          gender,
                          interviewee,
                          visitMatter,
                          startDate,
                          endDate
                        ]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访人 来访事由 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [
                          gender,
                          interviewee,
                          visitMatter,
                          licensePlateNumber
                        ]);
                  } else {
                    //性别 被访人 来访事由 车牌号码  结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          gender,
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访人 来访事由 车牌号码  开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          gender,
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //性别 被访人 来访事由 车牌号码  开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          gender,
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            }
          }
        } else {
          if (TextUtil.isEmpty(interviewee)) {
            if (TextUtil.isEmpty(visitMatter)) {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访部门
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ?',
                        whereArgs: [gender, departmentInterviewee]);
                  } else {
                    //性别 被访部门 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnRegistrationDate <= ?',
                        whereArgs: [gender, departmentInterviewee, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访部门 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnRegistrationDate >= ?',
                        whereArgs: [gender, departmentInterviewee, startDate]);
                  } else {
                    //性别 被访部门 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          startDate,
                          endDate
                        ]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访部门 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          licensePlateNumber
                        ]);
                  } else {
                    //性别 被访部门 车牌号码 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访部门  车牌号码 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //性别 被访部门 车牌号码 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            } else {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访部门 来访事由
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? ',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          visitMatter
                        ]);
                  } else {
                    //性别 被访部门 来访事由 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          visitMatter,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访部门 来访事由 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          visitMatter,
                          startDate
                        ]);
                  } else {
                    //性别 被访部门 来访事由 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          visitMatter,
                          startDate,
                          endDate
                        ]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访部门 来访事由 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          visitMatter,
                          licensePlateNumber
                        ]);
                  } else {
                    //性别 被访部门 来访事由 车牌号码 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          visitMatter,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访部门  来访事由 车牌号码 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //性别 被访部门 来访事由 车牌号码 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            }
          } else {
            if (TextUtil.isEmpty(visitMatter)) {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访部门 被访人
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          interviewee
                        ]);
                  } else {
                    //性别 被访部门 被访人 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          interviewee,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访部门 被访人 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          interviewee,
                          startDate
                        ]);
                  } else {
                    //性别 被访部门 被访人 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          interviewee,
                          startDate,
                          endDate
                        ]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访部门 被访人 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          interviewee,
                          licensePlateNumber
                        ]);
                  } else {
                    //性别 被访部门 被访人 车牌号码 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          interviewee,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访部门  被访人 车牌号码 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          interviewee,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //性别 被访部门 被访人 车牌号码 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          interviewee,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            } else {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访部门 被访人 来访事由
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? ',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          interviewee,
                          visitMatter
                        ]);
                  } else {
                    //性别 被访部门 被访人 来访事由 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访部门 被访人 来访事由 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          startDate
                        ]);
                  } else {
                    //性别 被访部门 被访人 来访事由 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          startDate,
                          endDate
                        ]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访部门 被访人 来访事由 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          licensePlateNumber
                        ]);
                  } else {
                    //性别 被访部门 被访人 来访事由 车牌号码 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //性别 被访部门  被访人 来访事由 车牌号码 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //性别 被访部门 被访人 来访事由 车牌号码 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          gender,
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            }
          }
        }
      }
    } else {
      if (TextUtil.isEmpty(gender)) {
        if (TextUtil.isEmpty(departmentInterviewee)) {
          if (TextUtil.isEmpty(interviewee)) {
            if (TextUtil.isEmpty(visitMatter)) {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名
                    maps = await db!.query(tableVisitor,
                        where: '$columnName = ?', whereArgs: [name]);
                  } else {
                    //姓名 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnRegistrationDate <= ?',
                        whereArgs: [name, endDate]);
                  }
                } else {
                  //姓名 开始日期
                  if (TextUtil.isEmpty(endDate)) {
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnRegistrationDate >= ?',
                        whereArgs: [name, startDate]);
                  } else {
                    //姓名 开始日期  结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [name, startDate, endDate]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [name, columnLicensePlateNumber]);
                  } else {
                    //姓名 车牌号码 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate',
                        whereArgs: [name, licensePlateNumber, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 车牌号码 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate',
                        whereArgs: [name, licensePlateNumber, startDate]);
                  } else {
                    //姓名 车牌号码 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            } else {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 来访事由
                    maps = await db!.query(tableVisitor,
                        where: '$columnName = ? and $columnVisitingMatters = ?',
                        whereArgs: [name, visitMatter]);
                  } else {
                    //姓名 来访事由 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnVisitingMatters = ? and $columnRegistrationDate <= ?',
                        whereArgs: [name, visitMatter, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 来访事由 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnVisitingMatters = ? and $columnRegistrationDate >= ?',
                        whereArgs: [name, visitMatter, startDate]);
                  } else {
                    //姓名 来访事由 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnVisitingMatters = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [name, visitMatter, startDate, endDate]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 来访事由 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [name, visitMatter, licensePlateNumber]);
                  } else {
                    //姓名 来访事由 车牌号码 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          visitMatter,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 来访事由 车牌号码 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          visitMatter,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //姓名 来访事由 车牌号码 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnVisitingMatters = and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          visitMatter,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            }
          } else {
            if (TextUtil.isEmpty(visitMatter)) {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访人
                    maps = await db!.query(tableVisitor,
                        where: '$columnInterviewee = ? ',
                        whereArgs: [name, interviewee]);
                  } else {
                    //姓名 被访人 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnInterviewee = ? and $columnRegistrationDate <= ? ',
                        whereArgs: [name, interviewee, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访人 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnInterviewee = ? and $columnRegistrationDate >= ?',
                        whereArgs: [name, interviewee, startDate]);
                  } else {
                    //姓名 被访人 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnInterviewee = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [name, interviewee, startDate, endDate]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访人 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnInterviewee = ?  and $columnLicensePlateNumber = ?',
                        whereArgs: [name, interviewee, licensePlateNumber]);
                  } else {
                    //姓名 被访人 车牌号码 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnInterviewee = ?  and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          interviewee,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访人 车牌号码 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          interviewee,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //姓名 被访人 车牌号码 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          interviewee,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            } else {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访人 来访事项
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnInterviewee = ? and $columnVisitingMatters = ?',
                        whereArgs: [name, interviewee, visitMatter]);
                  } else {
                    //姓名 被访人 来访事项  结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate <= ?',
                        whereArgs: [name, interviewee, visitMatter, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访人 来访事项  开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate >= ?',
                        whereArgs: [name, interviewee, visitMatter, startDate]);
                  } else {
                    //姓名 被访人 来访事项  开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          interviewee,
                          visitMatter,
                          startDate,
                          endDate
                        ]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访人 来访事由 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [
                          name,
                          interviewee,
                          visitMatter,
                          licensePlateNumber
                        ]);
                  } else {
                    //姓名 被访人 来访事由 车牌号码  结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访人 来访事由 车牌号码  开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //姓名 被访人 来访事由 车牌号码  开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            }
          }
        } else {
          if (TextUtil.isEmpty(interviewee)) {
            if (TextUtil.isEmpty(visitMatter)) {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访部门
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ?',
                        whereArgs: [name, departmentInterviewee]);
                  } else {
                    //姓名 被访部门 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnRegistrationDate <= ?',
                        whereArgs: [name, departmentInterviewee, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访部门 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnRegistrationDate >= ?',
                        whereArgs: [name, departmentInterviewee, startDate]);
                  } else {
                    //姓名 被访部门 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          startDate,
                          endDate
                        ]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访部门 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          licensePlateNumber
                        ]);
                  } else {
                    //姓名 被访部门 车牌号码 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访部门  车牌号码 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //姓名 被访部门 车牌号码 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            } else {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访部门 来访事由
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? ',
                        whereArgs: [name, departmentInterviewee, visitMatter]);
                  } else {
                    //姓名 被访部门 来访事由 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          visitMatter,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访部门 来访事由 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          visitMatter,
                          startDate
                        ]);
                  } else {
                    //姓名 被访部门 来访事由 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          visitMatter,
                          startDate,
                          endDate
                        ]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访部门 来访事由 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          visitMatter,
                          licensePlateNumber
                        ]);
                  } else {
                    //姓名 被访部门 来访事由 车牌号码 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          visitMatter,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访部门  来访事由 车牌号码 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //姓名 被访部门 来访事由 车牌号码 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            }
          } else {
            if (TextUtil.isEmpty(visitMatter)) {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访部门 被访人
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ?',
                        whereArgs: [name, departmentInterviewee, interviewee]);
                  } else {
                    //姓名 被访部门 被访人 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          interviewee,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访部门 被访人 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          interviewee,
                          startDate
                        ]);
                  } else {
                    //姓名 被访部门 被访人 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          interviewee,
                          startDate,
                          endDate
                        ]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访部门 被访人 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          interviewee,
                          licensePlateNumber
                        ]);
                  } else {
                    //姓名 被访部门 被访人 车牌号码 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          interviewee,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访部门  被访人 车牌号码 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          interviewee,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //姓名 被访部门 被访人 车牌号码 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          interviewee,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            } else {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访部门 被访人 来访事由
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? ',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          interviewee,
                          visitMatter
                        ]);
                  } else {
                    //姓名 被访部门 被访人 来访事由 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访部门 被访人 来访事由 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          startDate
                        ]);
                  } else {
                    //姓名 被访部门 被访人 来访事由 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          startDate,
                          endDate
                        ]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访部门 被访人 来访事由 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          licensePlateNumber
                        ]);
                  } else {
                    //姓名 被访部门 被访人 来访事由 车牌号码 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访部门  被访人 来访事由 车牌号码 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //姓名 被访部门 被访人 来访事由 车牌号码 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            }
          }
        }
      } else {
        if (TextUtil.isEmpty(departmentInterviewee)) {
          if (TextUtil.isEmpty(interviewee)) {
            if (TextUtil.isEmpty(visitMatter)) {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别
                    maps = await db!.query(tableVisitor,
                        where: '$columnName = ? and $columnGender = ?',
                        whereArgs: [name, gender]);
                  } else {
                    //姓名 性别 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and  $columnGender = ? and $columnRegistrationDate <= ?',
                        whereArgs: [name, gender, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and  $columnGender = ? and $columnRegistrationDate >= ?',
                        whereArgs: [name, gender, startDate]);
                  } else {
                    //姓名 性别 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [name, gender, startDate, endDate]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [name, gender, columnLicensePlateNumber]);
                  } else {
                    //姓名 性别 车牌号码 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate',
                        whereArgs: [name, gender, licensePlateNumber, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 车牌号码 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate',
                        whereArgs: [
                          name,
                          gender,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //姓名 性别 车牌号码 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          gender,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            } else {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 来访事由
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnVisitingMatters = ?',
                        whereArgs: [name, gender, visitMatter]);
                  } else {
                    //姓名 性别 来访事由 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnVisitingMatters = ? and $columnRegistrationDate <= ?',
                        whereArgs: [name, gender, visitMatter, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 来访事由 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnVisitingMatters = ? and $columnRegistrationDate >= ?',
                        whereArgs: [name, gender, visitMatter, startDate]);
                  } else {
                    //姓名 性别 来访事由 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnVisitingMatters = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          gender,
                          visitMatter,
                          startDate,
                          endDate
                        ]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 来访事由 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [
                          name,
                          gender,
                          visitMatter,
                          licensePlateNumber
                        ]);
                  } else {
                    //姓名 性别 来访事由 车牌号码 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          gender,
                          visitMatter,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 来访事由 车牌号码 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          gender,
                          visitMatter,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //姓名 性别 来访事由 车牌号码 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnVisitingMatters = and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          gender,
                          visitMatter,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            }
          } else {
            if (TextUtil.isEmpty(visitMatter)) {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访人
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnInterviewee = ? ',
                        whereArgs: [name, gender, interviewee]);
                  } else {
                    //姓名 性别 被访人 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnInterviewee = ? and $columnRegistrationDate <= ? ',
                        whereArgs: [name, gender, interviewee, endDate]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访人 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnInterviewee = ? and $columnRegistrationDate >= ?',
                        whereArgs: [name, gender, interviewee, startDate]);
                  } else {
                    //姓名 性别 被访人 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnInterviewee = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          gender,
                          interviewee,
                          startDate,
                          endDate
                        ]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 被访人  车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnInterviewee = ?  and $columnLicensePlateNumber = ?',
                        whereArgs: [name, interviewee, licensePlateNumber]);
                  } else {
                    //姓名 被访人  车牌号码 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnInterviewee = ?  and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          interviewee,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访人 车牌号码 开始日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          gender,
                          interviewee,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //姓名 性别 被访人 车牌号码 开始日期 结束日期
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          gender,
                          interviewee,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            } else {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访人 来访事项
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnInterviewee = ? and $columnVisitingMatters = ?',
                        whereArgs: [name, gender, interviewee, visitMatter]);
                  } else {
                    //姓名 性别 被访人 来访事项  结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          gender,
                          interviewee,
                          visitMatter,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访人 来访事项  开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          gender,
                          interviewee,
                          visitMatter,
                          startDate
                        ]);
                  } else {
                    //姓名 性别 被访人 来访事项  开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          gender,
                          interviewee,
                          visitMatter,
                          startDate,
                          endDate
                        ]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访人 来访事由 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [
                          name,
                          gender,
                          interviewee,
                          visitMatter,
                          licensePlateNumber
                        ]);
                  } else {
                    //姓名 性别 被访人 来访事由 车牌号码  结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          gender,
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访人 来访事由 车牌号码  开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          gender,
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //姓名 性别 被访人 来访事由 车牌号码  开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          gender,
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            }
          }
        } else {
          if (TextUtil.isEmpty(interviewee)) {
            if (TextUtil.isEmpty(visitMatter)) {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访部门
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ?',
                        whereArgs: [name, gender, departmentInterviewee]);
                  } else {
                    //姓名 性别 被访部门 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访部门 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          startDate
                        ]);
                  } else {
                    //姓名 性别 被访部门 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          startDate,
                          endDate
                        ]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访部门 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          licensePlateNumber
                        ]);
                  } else {
                    //姓名 性别 被访部门 车牌号码 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访部门  车牌号码 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //姓名 性别 被访部门 车牌号码 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            } else {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访部门 来访事由
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? ',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          visitMatter
                        ]);
                  } else {
                    //姓名 性别 被访部门 来访事由 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          visitMatter,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访部门 来访事由 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          visitMatter,
                          startDate
                        ]);
                  } else {
                    //姓名 性别 被访部门 来访事由 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          visitMatter,
                          startDate,
                          endDate
                        ]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访部门 来访事由 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          visitMatter,
                          licensePlateNumber
                        ]);
                  } else {
                    //姓名 性别 被访部门 来访事由 车牌号码 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          visitMatter,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访部门 来访事由 车牌号码 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //姓名 性别 被访部门 来访事由 车牌号码 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            }
          } else {
            if (TextUtil.isEmpty(visitMatter)) {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访部门 被访人
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          interviewee
                        ]);
                  } else {
                    //姓名 性别 被访部门 被访人 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          interviewee,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访部门 被访人 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          interviewee,
                          startDate
                        ]);
                  } else {
                    //姓名 性别 被访部门 被访人 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          interviewee,
                          startDate,
                          endDate
                        ]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访部门 被访人 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          interviewee,
                          licensePlateNumber
                        ]);
                  } else {
                    //姓名 性别 被访部门 被访人 车牌号码 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          interviewee,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访部门  被访人 车牌号码 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          interviewee,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //姓名 性别 被访部门 被访人 车牌号码 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          interviewee,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            } else {
              if (TextUtil.isEmpty(licensePlateNumber)) {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访部门 被访人 来访事由
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? ',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          interviewee,
                          visitMatter
                        ]);
                  } else {
                    //姓名 性别 被访部门 被访人 来访事由 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访部门 被访人 来访事由 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          startDate
                        ]);
                  } else {
                    //姓名 性别 被访部门 被访人 来访事由 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          startDate,
                          endDate
                        ]);
                  }
                }
              } else {
                if (TextUtil.isEmpty(startDate)) {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访部门 被访人 来访事由 车牌号码
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          licensePlateNumber
                        ]);
                  } else {
                    //姓名 性别 被访部门 被访人 来访事由 车牌号码 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate <= ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          endDate
                        ]);
                  }
                } else {
                  if (TextUtil.isEmpty(endDate)) {
                    //姓名 性别 被访部门  被访人 来访事由 车牌号码 开始时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate >= ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate
                        ]);
                  } else {
                    //姓名 性别 被访部门 被访人 来访事由 车牌号码 开始时间 结束时间
                    maps = await db!.query(tableVisitor,
                        where:
                            '$columnName = ? and $columnGender = ? and $columnDepartmentInterviewed = ? and $columnInterviewee = ? and $columnVisitingMatters = ? and $columnLicensePlateNumber = ? and $columnRegistrationDate between ? and ?',
                        whereArgs: [
                          name,
                          gender,
                          departmentInterviewee,
                          interviewee,
                          visitMatter,
                          licensePlateNumber,
                          startDate,
                          endDate
                        ]);
                  }
                }
              }
            }
          }
        }
      }
    }

    if (maps.length > 0) {
      maps.forEach((element) {
        allVisitor!.add(Visitor.fromMap(element));
      });
      close();
      return allVisitor;
    }
    close();
    return null;
  }
}
